package vn.appmobi.comictp;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class SplashActivity extends FragmentActivity {
	
	private static final int SPLASH_COUNT_TIME = 2000;
	private boolean actived = false;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		((ImageView) findViewById(R.id.splash)).setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				actived = true;
				return true;
			}
		});
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				int waited = 0;
				while((waited <= SPLASH_COUNT_TIME) && !actived) {
					waited += 100;
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				Intent intent = new Intent(SplashActivity.this, MainActivity.class);
				startActivity(intent);
				finish();
			}
		}).start();
	}

}
